package org.onvivals.app.modules.ums.controller;

import cn.hutool.core.util.StrUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onvivals.app.modules.auth.util.SaTokenUtil;
import org.onvivals.app.modules.ums.param.UserEditParam;
import org.onvivals.common.web.Result;
import org.onvivals.module.ums.entity.UmsFeedBack;
import org.onvivals.module.ums.entity.UmsUser;
import org.onvivals.module.ums.service.IUmsFeedBackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Tag(name = "小程序:意见反馈")
@RequestMapping("/feedback")
public class UmsFeedBackController {

	private final IUmsFeedBackService feedBackService;

	@PostMapping
	@Operation(summary = "意见反馈")
	public Result<Object> edit(@Validated @RequestBody UmsFeedBack umsFeedBack) {
		UmsUser member = SaTokenUtil.getUser();
		if (member == null) {
			return Result.error("用户不存在");
		}
		umsFeedBack.setUid(member.getUid());
		umsFeedBack.setContent(umsFeedBack.getContent());
		feedBackService.save(umsFeedBack);
		return Result.ok("反馈成功");
	}

}
